package kuaidi.view.activity;

import android.app.Application;

import com.baidu.mapapi.SDKInitializer;

import java.io.File;

import cn.finalteam.okhttpfinal.OkHttpFinal;
import cn.finalteam.okhttpfinal.OkHttpFinalConfiguration;
import kuaidi.utils.AppConfig;
import okhttp3.Cache;

/**
 * Created by Jhon on 2016/10/31.
 */

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        //在使用SDK各组件之前初始化context信息，传入ApplicationContext
        //注意该方法要再setContentView方法之前实现
        SDKInitializer.initialize(getApplicationContext());
        initFinalConfig();
    }


    private void initFinalConfig() {
        Cache cache = new Cache(new File(getExternalCacheDir() + AppConfig.JSON_CACHE), AppConfig.JSON_CACHE_SIZE);
        OkHttpFinalConfiguration configuration = new OkHttpFinalConfiguration.Builder()
                .setCache(cache)
                .build();
        OkHttpFinal.getInstance().init(configuration);
    }
}
